/**
 * Created by Administrator on 2017/5/26.
 */

var Url = {
    /**
     *
     *获取当前页面请求url对应的参数值
     * @param paramName 参数值对应的key值
     * @returns {string} key值对应的value
     */

    'getQueryParam' : function (name)
    {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)
            return  unescape(r[2]);
        return null;
    },

    'getParam' : function (paramName) {
        //对应key 返回对应的value
        var paramValue = "";
        //是否查找到标志
        var isFound = false;
        if (this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) {
            //转换编码，截取字符串，按'&'分割字符串 剩余 key=value 为形式的数组
            var arrSource = decodeURI(this.location.search).substring(1, this.location.search.length).split("&");
            var i = 0;
            while (i < arrSource.length && !isFound) {
                if (arrSource[i].indexOf("=") > 0) {
                    //截取key 已小写形式比较
                    if (arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase()) {
                        //获取设置value值，
                        paramValue = arrSource[i].split("=")[1];
                        //标志设置为找到
                        isFound = true;
                    }
                }
                i++;
            }
        }
        return paramValue;
    },

    'getParamList' :function (isNeedInterrogationMark){
        if(isNeedInterrogationMark)
            return window.location.search;
        return window.location.search.substring(1);
    }


};




